package com.vm.adapter;

import java.util.List;
import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.vm.model.RememberPsd;
import com.wwtscapp.apk.R;

@SuppressLint("InflateParams")
public class RememberPsdAdapter extends BaseAdapter {
	private Context mContext;
	private List<RememberPsd> list;

	public RememberPsdAdapter(Context context, List<RememberPsd> lists) {
		this.mContext = context;
		this.list = lists;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder viewHolder = null;
		if (convertView == null) {

			convertView = LayoutInflater.from(mContext).inflate(
					R.layout.remember_psd_item, null);
			viewHolder = new ViewHolder();
			viewHolder.tv_username = (TextView) convertView
					.findViewById(R.id.tv_username);
			convertView.setTag(viewHolder);
		} else {
			viewHolder = (ViewHolder) convertView.getTag();
		}
		RememberPsd rememberPsd = list.get(position);
		if (rememberPsd.getPsd() != null) {
			viewHolder.tv_username.setTag(rememberPsd);
		}
		if (rememberPsd.getUsername() != null) {
			viewHolder.tv_username.setText(rememberPsd.getUsername());
		}
		return convertView;
	}

	static class ViewHolder {
		TextView tv_username;
	}
}